import { NgModule } from '@angular/core';
import { CommonModule }       from '@angular/common';

import { RoutingModule } from './router';

import { ReduxComponent } from './redux.component';

import { createStore, Store, compose, StoreEnhancer } from 'redux';
import { ReduxStore } from './store/store';
import { ReduxState, default as reducer } from './reducers';
import ChatThreads from './containers/ChatThreads';
import ChatThread from './components/ChatThread';

let devtools: StoreEnhancer<ReduxState> = 
	window['devToolsExtension'] ?
	window['devToolsExtension']() : f => f;


let store: Store<ReduxState> = createStore<ReduxState>(
  reducer,
  compose(devtools)
);

@NgModule({
    imports: [
        CommonModule,
        RoutingModule,
    ],
    declarations: [
        ReduxComponent,
        ChatThreads,
        ChatThread,
    ],
    providers: [
	    { provide: ReduxStore, useFactory: () => store }
	  ]
})

export class Module {}